//
//  ZDBSearchView.swift
//  XinLangMicroblog
//
//  Created by MackBook on 16/9/23.
//  Copyright © 2016年 zx540006260. All rights reserved.
//

import UIKit

@IBDesignable class ZDBSearchView: UIButton {
    
    //视图被激活的时候调用方法
    
    override func awakeFromNib() {
        
        //图片距离view的边距
        
        self.imageEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
        
        //文字距离view的边距
        
        self.titleEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0)
        
        //设置XIB中button的宽度与屏幕宽度相等
        
        self.bounds.size.width = UIScreen.main.bounds.width
        
        //MARK:设置自定义搜索栏(navigationItem)的圆角效果,还有storyboard方法
        
        //        self.layer.cornerRadius = 13
        //
        //        self.layer.masksToBounds = true
        
        //@IBAction
        //@IBOutlet
        //@IBInspectable 定义可视化属性
        //@IBDesignable 让可视化属性时时刷新
        
    }
    
    //MARK:定义类方法加载该视图中的文件
    
    class func loadSearchView () -> ZDBSearchView {
        
        let nib = UINib.init(nibName: "ZDBSearchView", bundle: nil)
        
        let searchView = nib.instantiate(withOwner: nil, options: nil).last as! ZDBSearchView
        
        return searchView
        
    }
    
}
